<?php
//discount percent
$discount = BUtils::GetDiscount($row['value'], $row['price']);
$discount_string = empty($discount) ? '%' : sprintf('%d', $discount) . '%';

//price
$price = Yii::app()->locale->numberFormatter->formatCurrency($row['value'], '');
$value = Yii::app()->locale->numberFormatter->formatCurrency($row['price'], '');

// valid time
$hour_range_array = BUtils::DinnerHourRange();
$selected_hour_range_html = BUtils::GetLunchHourRange($row['start_hour'], $row['end_hour']);
$selected_hour_range_html = empty($selected_hour_range_html) ? $hour_range_array[1] : $selected_hour_range_html;

// week days
$selected_week_days_html = SpecialForm::HtmlWeekdays($row['week_days'], BUtils::WeekDayKeys(7));

//valida date
$selected_valid_date_html = BUtils::GetDateRangeString($row['uts_start_date'], $row['uts_end_date'], 'd.m.Y');

//logo_picture
$url_picture = empty($row['url_picture']) ? $row['url_logo'] : $row['url_picture'];

//special title
$special_title = ($row['type'] == 1) ? BUtils::T('lunch_special_lbl') : BUtils::T('special_lbl');

//add class for valid calss=?
if ($row['uts_end_date'] < time()) $discount_class = 'expired';
else if ($row['uts_start_date'] > time()) $discount_class = 'upcoming';
else $discount_class = '';
?>
<div class="form" style="padding:10px;">
	<div class="fieldswrap special relative <?php echo $discount_class; ?>">
		<div class="discount-box <?php echo $discount_class; ?>">
			<span class="special-discount"><?php echo $discount_string; ?></span>
		</div>
		<div class="bar">
			<div class="title"><?php echo $special_title; ?></div>
		</div>
		<div class="panel">
			<div class="left" style="margin-right:10px;">
				<img class="picture" width="80" src="<?php echo $url_picture; ?>">
			</div>
			<div>
				<div class="title"><?php echo $row['name']; ?></div>
				<div class="address"><?php echo BUtils::GetAddress($row['address'], $row['postcode'], $row['city']); ?></div>
			</div>
			<div class="clear"></div>
			<div class="text" id="special-content"><?php echo nl2br($row['content']); ?></div>
		</div>
		<div class="offer" id="time-section">
			<div class="icon"><img src="<?php echo Yii::app()->baseUrl; ?>/images/icons/clock_26x26.png" alg=""></div>
			<div class="text">
				<div class="hour-range" id="hour-range"><?php echo $selected_hour_range_html; ?></div>
				<div class="week-days" id="week-days"><?php echo $selected_week_days_html; ?></div>
				<div class="valid-date" id="valid-date"><?php echo $selected_valid_date_html; ?></div>
			</div>
			<div class="clear"></div>
		</div>
		<div class="offer" id="price-section">
			<div class="icon"><img src="<?php echo Yii::app()->baseUrl; ?>/images/icons/sale_26x26.png" alg=""></div>
			<div class="text">
				<span class="price"><span class="currency">€</span><span id="price"><?php echo $price; ?></span></span>
				<span class="oldprice space-1" id="value"><?php echo $value; ?></span></div>
			<div class="clear"></div>
		</div>
	</div>
</div>